Friend Class DBScanQueue
    Inherits DBBase

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub Load(ByRef oObject As SQLAutoDocLib.ScanQueue)
        Dim sSQL As String = "select"
        sSQL = sSQL & "     a.[SessionID],"
        sSQL = sSQL & "     a.[ServerID],"
        sSQL = sSQL & "     a.[DatabaseID],"
        sSQL = sSQL & "     a.[ScanTypeID],"
        sSQL = sSQL & "     a.[ScanStart],"
        sSQL = sSQL & "     a.[ScanComplete],"

        sSQL = sSQL & "     a.[CreateName],"
        sSQL = sSQL & "     a.[CreateDate],"
        sSQL = sSQL & "     a.[ChangeName],"
        sSQL = sSQL & "     a.[ChangeDate]"
        sSQL = sSQL & " from"
        sSQL = sSQL & "     ScanQueue a"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     a.[ID]=" & oObject.ID

        Dim oData As DataTable = MyBase.ExecuteReadToDataTable(sSQL)

        If oData.Rows.Count > 0 Then
            With oObject
                .SessionID = oData.Rows(0).Item("SessionID")
                .ServerID = oData.Rows(0).Item("ServerID")
                .DatabaseID = oData.Rows(0).Item("DatabaseID")
                .ScanTypeID = oData.Rows(0).Item("ScanTypeID")
                .ScanStart = NullToString(oData.Rows(0).Item("ScanStart"))
                .ScanComplete = NullToString(oData.Rows(0).Item("ScanComplete"))

                .CreateName = oData.Rows(0).Item("CreateName")
                .CreateDate = oData.Rows(0).Item("CreateDate")
                .ChangeName = NullToString(oData.Rows(0).Item("ChangeName"))
                .ChangeDate = NullToString(oData.Rows(0).Item("ChangeDate"))
            End With
        Else
            oObject._ObjectExists = False
        End If

        oData.Dispose()
    End Sub

    Public Sub Update(ByRef oObject As SQLAutoDocLib.ScanQueue)
        Dim sSQL As String = "update ScanQueue set"
        sSQL = sSQL & "     [SessionID]=" & ValueToDBValue(oObject.SessionID) & ","
        sSQL = sSQL & "     [ServerID]=" & ValueToDBValue(oObject.ServerID) & ","
        sSQL = sSQL & "     [DatabaseID]=" & ValueToDBValue(oObject.DatabaseID) & ","
        sSQL = sSQL & "     [ScanTypeID]=" & ValueToDBValue(Val(oObject.ScanTypeID)) & ","
        sSQL = sSQL & "     [ScanStart]=" & ValueToDBValue(oObject.ScanStart) & ","
        sSQL = sSQL & "     [ScanComplete]=" & ValueToDBValue(oObject.ScanComplete) & ","

        sSQL = sSQL & "     [CreateName]=" & ValueToDBValue(oObject.CreateName) & ","
        sSQL = sSQL & "     [CreateDate]=" & ValueToDBValue(oObject.CreateDate) & ","
        sSQL = sSQL & "     [ChangeName]=" & ValueToDBValue(oObject.ChangeName) & ","
        sSQL = sSQL & "     [ChangeDate]=" & ValueToDBValue(oObject.ChangeDate)
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [ID]=" & oObject.ID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub Add(ByRef oObject As SQLAutoDocLib.ScanQueue)
        Dim sSQL As String = "insert into ScanQueue ("
        sSQL = sSQL & "     [ID],"
        sSQL = sSQL & "     [SessionID],"
        sSQL = sSQL & "     [ServerID],"
        sSQL = sSQL & "     [DatabaseID],"
        sSQL = sSQL & "     [ScanTypeID],"
        sSQL = sSQL & "     [ScanStart],"
        sSQL = sSQL & "     [ScanComplete],"

        sSQL = sSQL & "     [CreateName],"
        sSQL = sSQL & "     [CreateDate],"
        sSQL = sSQL & "     [ChangeName],"
        sSQL = sSQL & "     [ChangeDate]) values ("

        sSQL = sSQL & ValueToDBValue(oObject.ID) & ","
        sSQL = sSQL & ValueToDBValue(oObject.SessionID) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ServerID) & ","
        sSQL = sSQL & ValueToDBValue(oObject.DatabaseID) & ","
        sSQL = sSQL & ValueToDBValue(Val(oObject.ScanTypeID)) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ScanStart) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ScanComplete) & ","

        sSQL = sSQL & ValueToDBValue(oObject.CreateName) & ","
        sSQL = sSQL & ValueToDBValue(oObject.CreateDate) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ChangeName) & ","
        sSQL = sSQL & ValueToDBValue(oObject.ChangeDate) & ")"

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub Delete(ByRef oObject As SQLAutoDocLib.ScanQueue)
        Dim sSQL As String = "delete from ScanQueue"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [ID]=" & oObject.ID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub
End Class
